﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Windows;
using System.Collections.Generic;
using System.IO;
using System.Drawing;
using LEDManager;
using System.Text;
public partial class LEDSVCWIN
{

    LEDConsole2 led;
    ArrayList textlist = new ArrayList();
    ArrayList fontlist = new ArrayList();
    private void SaveToFile(byte[] value, string filePath)
    {
        System.IO.FileStream fs = new System.IO.FileStream(filePath, System.IO.FileMode.OpenOrCreate);
        fs.Write(value, 0, value.Length);
        fs.Flush();
        fs.Close();
    }
    private Bitmap BitmapFromByteArray(byte[] byteArray)
    {
        int n = 0;
        // Get the width
        uint x = (((uint)byteArray[n] * 256 + (uint)byteArray[n + 1]) * 256 + (uint)byteArray[n + 2]) * 256 + (uint)byteArray[n + 3];
        int width = (int)x;
        n += 4;
        // Get the height
        x = (((uint)byteArray[n] * 256 + (uint)byteArray[n + 1]) * 256 + (uint)byteArray[n + 2]) * 256 + (uint)byteArray[n + 3];
        int height = (int)x;
        n += 4;
        // Create the Bitmmap object
        Bitmap bmp = new Bitmap(width, height);
        // The pixels are stored in order by rows
        for (int j = 0; j < height; j++)
        {
            // Read the pixels for each row
            for (int i = 0; i < width; i++)
            {
                x = (((uint)byteArray[n] * 256 + (uint)byteArray[n + 1]) * 256 + (uint)byteArray[n + 2]) * 256 + (uint)byteArray[n + 3];
                bmp.SetPixel(i, j, Color.FromArgb((int)x));
                n += 4;
            }
        }
        return bmp;
    }
    public object SendLED(string ctype, Dictionary<string, string> para)
    {
        object result = null;
        int nLEDID = 1;
        int iValue = 0;
        int iOUTPUTIP = 0;
        int iPower = 0;
        string szBmpFile = "";
        string RootType, ColorMode, survive;
        string ActionMode;
        Int32 ChapterIndex, RegionIndex, LeafIndex, ObjectIndex;
        ushort num;
        UInt32 time;
        string wait;
        Int32 startx, starty, width, height, border, vertical, stretch;
        string fontstyle, bordershape;
        Int32 transparent, fontcolor, fontsize, wordwrap, alignment, inmethod, inspeed, outmethod, outspeed, stopmethod, stopspeed, stoptime;
        string fontname, text, picture, format;
        Int32 src_width, src_height;
        Int32 year_offset, month_offset, day_offset, sec_offset;
        Int32 offset, dotradius, adotwidth, bdotwidth, cdotwidth, hourwidth, minutewidth, secondwidth;
        UInt32 bkcolor, bordercolor, borderwidth, adotcolor, bdotcolor, cdotcolor, minutecolor, secondcolor, hourcolor, cdotvisible;

        int iTextid = 0;
        switch (ctype)
        {
            case "LED_GetLEDList":
                result = led.LED_GetLEDList();
                break;
            case "LED_GetText":
                iTextid = System.Convert.ToInt32(para["TEXTID"].ToString());
                result = textlist[iTextid];
                break;
            case "LED_Registration":
                nLEDID = System.Convert.ToInt32(para["LEDID"].ToString());
                string Lprefix = System.Convert.ToString(para["LLLEDPRE"].ToString());
                string Lnumber = System.Convert.ToString(para["LLLEDNUMBER"].ToString());
                string mac = System.Convert.ToString(para["MACADDRESS"].ToString());
                string ip = System.Convert.ToString(para["IPADDRESS"].ToString());
                string devtyp = System.Convert.ToString(para["DEVTYPE"].ToString());
                string bit = System.Convert.ToString(para["DSPEED"].ToString());
                string locport = System.Convert.ToString(para["LOCPORT"].ToString());
                string comport = System.Convert.ToString(para["COMPORT"].ToString());
                string stype = System.Convert.ToString(para["LLSCREENTYPE"].ToString());
                string rmtport = System.Convert.ToString(para["REMOTPORT"].ToString());
                string dstAdd = System.Convert.ToString(para["DSTADD"].ToString());
                string Lwidth = System.Convert.ToString(para["WIDTH"].ToString());
                string Lheight = System.Convert.ToString(para["HEIGHT"].ToString());
                string nuser = System.Convert.ToString(para["NEWDATE"].ToString());
                string ndate = System.Convert.ToString(para["NEWUSER"].ToString());
                string cuser = System.Convert.ToString(para["LASTDATE"].ToString());
                string cdate = System.Convert.ToString(para["LASTUSER"].ToString());
                result = led.LED_Registration(nLEDID, Lprefix, Lnumber, ip,mac, devtyp, bit, locport, comport, stype, rmtport, dstAdd, Lwidth, Lheight, nuser, ndate, cuser,cdate);
                break;
            /*            public void LED_Registration(int nLEDID,string prefix,string number,string ip,string mac,string devtyp,string bit,string locport,string comport,string stype,
            string rmtport,string dstAdd,string width,string height)
        { 
          
        
        }*/
            case "LED_GetFont":
                iTextid = System.Convert.ToInt32(para["FONTID"].ToString());
                result = fontlist[iTextid];
                break;
            case "LED_SavePicture":
                szBmpFile = para["PICTURENAME"].ToString();
                string file = "D:/SXDFile/" + szBmpFile;
                if (System.IO.File.Exists(file))
                {
                    System.IO.File.Delete(file);
                }
                string patternStr = para["PVALUE"].ToString();
                byte[] ba = Convert.FromBase64String(patternStr);
                //Image  bmp = BitmapFromByteArray(ba);
                SaveToFile(ba, file);
                break;
            case "ResetLedData":
                led.ResetLedData();
                break;
            case "LED_Startup":
                if (led == null)
                {
                    led = new LEDConsole2();
                    textlist.Add(" 0 = 随机");
                    textlist.Add("1立即显示");
                    textlist.Add("2左滚显示");
                    textlist.Add("3上滚显示");
                    textlist.Add("4右滚显示");
                    textlist.Add("5下滚显示");
                    textlist.Add("6连续左滚显示");
                    textlist.Add("7连续下滚显示");
                    textlist.Add("8中间向上下展开");
                    textlist.Add("9中间向两边展开");
                    textlist.Add("10中间向四周展开");
                    textlist.Add("11从右向左移入'");
                    textlist.Add("12从左向右移入");
                    textlist.Add("13从左向右展开");
                    textlist.Add("14从右向左展开");
                    textlist.Add("15从右上角移入");
                    textlist.Add("16从右下角移入");
                    textlist.Add("17从左上角移入");
                    textlist.Add("18从左下角移入");
                    textlist.Add("19从上向下移入");
                    textlist.Add("20从下向上移入");
                    textlist.Add("21横向百叶窗");
                    textlist.Add("22纵向百叶窗'");
                    textlist.Add("23普通消息,地铁免费啦.");
                    textlist.Add("24断电后持续:珍惜生命，严禁酒后驾车。开车时请您系好安全带。");
                    textlist.Add("25紧急通知:地铁收费啦。");
                    fontlist.Add("宋体");
                    fontlist.Add("楷体");
                    fontlist.Add("黑体");
                }
                //led.XLED_Startup();
                iValue = System.Convert.ToInt32(para["RESETDATA"].ToString());
                if (iValue == 1)
                {
                    led.ResetLedData();
                }
                led.Show();
                result = "Service Started";
                break;
            case "LED_Cleanup":
                led.XLED_Cleanup();
                break;
            ////设置控制卡电源 value=LED_POWER_ON表示开启电源 value=LED_POWER_OFF表示关闭电源
            case "LED_SetPower":
                nLEDID = System.Convert.ToInt32(para["LEDID"].ToString());
                iPower = System.Convert.ToInt32(para["POWER"].ToString());
                if (para.ContainsKey("OUTPUTIP"))
                {
                    iOUTPUTIP = System.Convert.ToInt32(para["OUTPUTIP"].ToString());
                }
                result = led.LED_SetPower(nLEDID, iPower, iOUTPUTIP);
                break;
            //读取控制卡电源状态
            case "LED_GetPower":
                nLEDID = System.Convert.ToInt32(para["LEDID"].ToString());
                result = led.LED_GetPower(nLEDID);
                break;
            //设置控制卡亮度 value取值范围0-7
            case "LED_SetBright":
                nLEDID = System.Convert.ToInt32(para["LEDID"].ToString());
                iValue = System.Convert.ToInt32(para["BRIGHT"].ToString());
                result = led.LED_SetBright(nLEDID, iValue);
                break;
            //读取控制卡亮度
            case "LED_GetBright":
                nLEDID = System.Convert.ToInt32(para["LEDID"].ToString());
                result = led.LED_GetBright(nLEDID);
                break;
            case "LED_AdjustTime":
                nLEDID = System.Convert.ToInt32(para["LEDID"].ToString());
                result = led.LED_AdjustTime(nLEDID);
                break;
            case "LED_GetPlayContent":
                nLEDID = System.Convert.ToInt32(para["LEDID"].ToString());
                result = led.LED_GetPlayContent(nLEDID);
                break;


            case "LED_MakeRoot":
                #region===========================
                nLEDID = System.Convert.ToInt32(para["LEDID"].ToString());
                RootType = System.Convert.ToString(para["ROOTTYPE"].ToString());
                ColorMode = System.Convert.ToString(para["COLORMODE"].ToString());
                survive = System.Convert.ToString(para["SURVIVE"].ToString());
                result = led.LED_MakeRoot(nLEDID, RootType, ColorMode, survive);
                break;
                #endregion
            case "LED_MakeLeaf":
                #region===========================
                nLEDID = System.Convert.ToInt32(para["LEDID"].ToString());
                RootType = System.Convert.ToString(para["ROOTTYPE"].ToString());
                ActionMode = System.Convert.ToString(para["ACTIONMODE"].ToString());
                ChapterIndex = System.Convert.ToInt32(para["CHAPTERINDEX"].ToString());
                RegionIndex = System.Convert.ToInt32(para["REGIONINDEX"].ToString());
                LeafIndex = System.Convert.ToInt32(para["LEAFINDEX"].ToString());
                ColorMode = System.Convert.ToString(para["COLORMODE"].ToString());
                time = System.Convert.ToUInt32(para["TIME"].ToString());
                ColorMode = System.Convert.ToString(para["COLORMODE"].ToString());
                wait = System.Convert.ToString(para["WAIT"].ToString());
                result = led.LED_MakeLeaf(nLEDID, RootType, ActionMode, ChapterIndex, RegionIndex, LeafIndex, ColorMode, time, wait);
                break;
                #endregion
            case "LED_MakeChapter":
                #region===========================
                nLEDID = System.Convert.ToInt32(para["LEDID"].ToString());
                RootType = System.Convert.ToString(para["ROOTTYPE"].ToString());
                ActionMode = System.Convert.ToString(para["ACTIONMODE"].ToString());
                ChapterIndex = System.Convert.ToInt32(para["CHAPTERINDEX"].ToString());
                ColorMode = System.Convert.ToString(para["COLORMODE"].ToString());
                time = System.Convert.ToUInt32(para["TIME"].ToString());
                ColorMode = System.Convert.ToString(para["COLORMODE"].ToString());
                wait = System.Convert.ToString(para["WAIT"].ToString());
                result = led.LED_MakeChapter(nLEDID, RootType, ActionMode, ChapterIndex, ColorMode, time, wait);
                break;
                #endregion

            case "LED_AddChapter":
                #region===========================
                //LED_AddChapter(int nLEDID, int num, UInt32 time, string wait)
                nLEDID = System.Convert.ToInt32(para["LEDID"].ToString());
                num = System.Convert.ToUInt16(para["PNUM"].ToString());
                time = System.Convert.ToUInt32(para["TIME"].ToString());
                wait = System.Convert.ToString(para["WAIT"].ToString());
                result = led.LED_AddChapter(nLEDID, num, time, wait);

                break;
                #endregion
            case "LED_AddChapterEx":
                #region===========================
                //LED_AddChapter(int nLEDID, int num, UInt32 time, string wait)
                nLEDID = System.Convert.ToInt32(para["LEDID"].ToString());
                num = System.Convert.ToUInt16(para["PNUM"].ToString());
                time = System.Convert.ToUInt32(para["TIME"].ToString());
                wait = System.Convert.ToString(para["WAIT"].ToString());
                ushort kind = System.Convert.ToUInt16(para["KIND"].ToString());
                ushort week = System.Convert.ToUInt16(para["WEEK"].ToString());
                Int32 stime = System.Convert.ToInt32(para["STIME"].ToString());
                Int32 sdate = System.Convert.ToInt32(para["SDATE"].ToString());
                Int32 etime = System.Convert.ToInt32(para["ETIME"].ToString());
                Int32 edate = System.Convert.ToInt32(para["EDATE"].ToString());
                result = led.LED_AddChapterEx(nLEDID, num, time, wait, kind, week, stime, sdate, etime, edate);
                break;
                #endregion
            case "LED_AddRegion":
                #region===========================
                //LED_AddChapter(int nLEDID, int num, UInt32 time, string wait)
                nLEDID = System.Convert.ToInt32(para["LEDID"].ToString());
                num = System.Convert.ToUInt16(para["PNUM"].ToString());
                startx = System.Convert.ToInt32(para["STARTX"].ToString());
                starty = System.Convert.ToInt32(para["STARTY"].ToString());
                width = System.Convert.ToInt32(para["WIDTH"].ToString());
                height = System.Convert.ToInt32(para["HEIGHT"].ToString());
                border = System.Convert.ToInt32(para["BORDER"].ToString());
                result = led.LED_AddRegion(nLEDID, num, startx, starty, width, height, border);
                #endregion
                break;
            case "LED_AddLeaf":
                #region===========================
                //LED_AddChapter(int nLEDID, int num, UInt32 time, string wait)
                nLEDID = System.Convert.ToInt32(para["LEDID"].ToString());
                num = System.Convert.ToUInt16(para["PNUM"].ToString());
                time = System.Convert.ToUInt32(para["TIME"].ToString());
                wait = System.Convert.ToString(para["WAIT"].ToString());
                result = led.LED_AddLeaf(nLEDID, num, time, wait);
                #endregion
                break;
            case "LED_AddText":
                #region===========================
                nLEDID = System.Convert.ToInt32(para["LEDID"].ToString());
                num = System.Convert.ToUInt16(para["PNUM"].ToString());
                startx = System.Convert.ToInt32(para["STARTX"].ToString());
                starty = System.Convert.ToInt32(para["STARTY"].ToString());
                width = System.Convert.ToInt32(para["WIDTH"].ToString());
                height = System.Convert.ToInt32(para["HEIGHT"].ToString());
                transparent = System.Convert.ToInt32(para["TRANSPARENT"].ToString());
                border = System.Convert.ToInt32(para["BORDER"].ToString());
                text = System.Convert.ToString(para["TEXT"].ToString());
                fontname = System.Convert.ToString(para["FONTNAME"].ToString());
                fontsize = System.Convert.ToInt32(para["FONTSIZE"].ToString());
                fontcolor = System.Convert.ToInt32(para["FONTCOLOR"].ToString());
                fontstyle = System.Convert.ToString(para["FONTSTYLE"].ToString());
                wordwrap = System.Convert.ToInt32(para["WORDWRAP"].ToString());
                alignment = System.Convert.ToInt32(para["ALIGNMENT"].ToString());
                inmethod = System.Convert.ToInt32(para["INMETHOD"].ToString());
                inspeed = System.Convert.ToInt32(para["INSPEED"].ToString());
                outmethod = System.Convert.ToInt32(para["OUTMETHOD"].ToString());
                outspeed = System.Convert.ToInt32(para["OUTSPEED"].ToString());
                stopmethod = System.Convert.ToInt32(para["STOPMETHOD"].ToString());
                stopspeed = System.Convert.ToInt32(para["STOPSPEED"].ToString());
                stoptime = System.Convert.ToInt32(para["STOPTIME"].ToString());
                text = System.Text.Encoding.Default.GetString(System.Text.Encoding.GetEncoding("iso-8859-1").GetBytes(text as string));
                fontname = System.Text.Encoding.Default.GetString(System.Text.Encoding.GetEncoding("iso-8859-1").GetBytes(fontname as string));
                result = led.LED_AddText(nLEDID, num, startx, starty, width, height, transparent, border, text, fontname, fontsize, fontcolor, fontstyle, wordwrap, alignment, inmethod, inspeed, outmethod, outspeed, stopmethod, stopspeed, stoptime);
                #endregion
                break;
            case "LED_AddTextEx":
                #region===========================
                /*
                nLEDID = System.Convert.ToInt32(para["LEDID"].ToString());
                num = System.Convert.ToUInt16(para["PNUM"].ToString());
                startx = System.Convert.ToInt32(para["STARTX"].ToString());
                starty = System.Convert.ToInt32(para["STARTY"].ToString());
                width = System.Convert.ToInt32(para["WIDTH"].ToString());
                height = System.Convert.ToInt32(para["HEIGHT"].ToString());
                transparent = System.Convert.ToInt32(para["TRANSPARENT"].ToString());
                Int32 flag = System.Convert.ToInt32(para["FLAG"].ToString());
                text = System.Convert.ToString(para["TEXT"].ToString());
                fontname = System.Convert.ToString(para["FONTNAME"].ToString());
                fontsize = System.Convert.ToInt32(para["FONTSIZE"].ToString());
                fontcolor = System.Convert.ToInt32(para["FONTCOLOR"].ToString());
                fontstyle = System.Convert.ToString(para["FONTSTYLE"].ToString());
                wordwrap = System.Convert.ToInt32(para["WORDWRAP"].ToString());
                vertical = System.Convert.ToInt32(para["VERTICAL"].ToString());
                alignment = System.Convert.ToInt32(para["ALIGNMENT"].ToString());
               Int32 verticalspace = System.Convert.ToInt32(para["VERTICALSPACE"].ToString());
                Int32 horizontalfit = System.Convert.ToInt32(para["HORIZONTALFIT"].ToString());
                
                inmethod = System.Convert.ToInt32(para["INMETHOD"].ToString());
                inspeed = System.Convert.ToInt32(para["INSPEED"].ToString());
                outmethod = System.Convert.ToInt32(para["OUTMETHOD"].ToString());
                outspeed = System.Convert.ToInt32(para["OUTSPEED"].ToString());
                stopmethod = System.Convert.ToInt32(para["STOPMETHOD"].ToString());
                stopspeed = System.Convert.ToInt32(para["STOPSPEED"].ToString());
                stoptime = System.Convert.ToInt32(para["STOPTIME"].ToString());
                result = led.LED_AddTextEx3(nLEDID, num, startx, starty, width, height, transparent,flag,  text, fontname, fontsize, fontcolor, fontstyle, bkcolor,wordwrap,vertical,
                    alignment, verticalspace, horizontalfit, inmethod, inspeed, outmethod, outspeed, stopmethod, stopspeed, stoptime);
                
                           text = System.Text.Encoding.Default.GetString(System.Text.Encoding.GetEncoding("iso-8859-1").GetBytes(text as string));
                fontname = System.Text.Encoding.Default.GetString(System.Text.Encoding.GetEncoding("iso-8859-1").GetBytes(fontname as string));*/
                #endregion
                break;


            case "LED_AddWindow":
                #region===========================
                nLEDID = System.Convert.ToInt32(para["LEDID"].ToString());
                num = System.Convert.ToUInt16(para["PNUM"].ToString());
                startx = System.Convert.ToInt32(para["STARTX"].ToString());
                starty = System.Convert.ToInt32(para["STARTY"].ToString());
                width = System.Convert.ToInt32(para["WIDTH"].ToString());
                height = System.Convert.ToInt32(para["HEIGHT"].ToString());
                transparent = System.Convert.ToInt32(para["TRANSPARENT"].ToString());
                border = System.Convert.ToInt32(para["BORDER"].ToString());
                picture = System.Convert.ToString(para["PICTURE"].ToString());
                src_width = System.Convert.ToInt32(para["SWIDTH"].ToString());
                src_height = System.Convert.ToInt32(para["SHEIGHT"].ToString());
                alignment = System.Convert.ToInt32(para["ALIGNMENT"].ToString());
                inmethod = System.Convert.ToInt32(para["INMETHOD"].ToString());
                inspeed = System.Convert.ToInt32(para["INSPEED"].ToString());
                outmethod = System.Convert.ToInt32(para["OUTMETHOD"].ToString());
                outspeed = System.Convert.ToInt32(para["OUTSPEED"].ToString());
                stopmethod = System.Convert.ToInt32(para["STOPMETHOD"].ToString());
                stopspeed = System.Convert.ToInt32(para["STOPSPEED"].ToString());
                stoptime = System.Convert.ToInt32(para["STOPTIME"].ToString());
                result = led.LED_AddWindow(nLEDID, num, startx, starty, width, height, transparent, border, picture, src_width, src_height,
                    alignment, inmethod, inspeed, outmethod, outspeed, stopmethod, stopspeed, stoptime);
                #endregion
                break;
            case "LED_AddPicture":
                nLEDID = System.Convert.ToInt32(para["LEDID"].ToString());
                num = System.Convert.ToUInt16(para["PNUM"].ToString());
                startx = System.Convert.ToInt32(para["STARTX"].ToString());
                starty = System.Convert.ToInt32(para["STARTY"].ToString());
                width = System.Convert.ToInt32(para["WIDTH"].ToString());
                height = System.Convert.ToInt32(para["HEIGHT"].ToString());
                transparent = System.Convert.ToInt32(para["TRANSPARENT"].ToString());
                border = System.Convert.ToInt32(para["BORDER"].ToString());
                picture = System.Convert.ToString(para["PICTURE"].ToString());

                alignment = System.Convert.ToInt32(para["ALIGNMENT"].ToString());
                inmethod = System.Convert.ToInt32(para["INMETHOD"].ToString());
                inspeed = System.Convert.ToInt32(para["INSPEED"].ToString());
                outmethod = System.Convert.ToInt32(para["OUTMETHOD"].ToString());
                outspeed = System.Convert.ToInt32(para["OUTSPEED"].ToString());
                stopmethod = System.Convert.ToInt32(para["STOPMETHOD"].ToString());
                stopspeed = System.Convert.ToInt32(para["STOPSPEED"].ToString());
                stoptime = System.Convert.ToInt32(para["STOPTIME"].ToString());
                result = led.LED_AddPicture(nLEDID, num, startx, starty, width, height, transparent, border, picture
                    , alignment, inmethod, inspeed, outmethod, outspeed, stopmethod, stopspeed, stoptime);
                break;
            case "LED_AddMovie":
                nLEDID = System.Convert.ToInt32(para["LEDID"].ToString());
                num = System.Convert.ToUInt16(para["PNUM"].ToString());
                startx = System.Convert.ToInt32(para["STARTX"].ToString());
                starty = System.Convert.ToInt32(para["STARTY"].ToString());
                width = System.Convert.ToInt32(para["WIDTH"].ToString());
                height = System.Convert.ToInt32(para["HEIGHT"].ToString());
                transparent = System.Convert.ToInt32(para["TRANSPARENT"].ToString());
                border = System.Convert.ToInt32(para["BORDER"].ToString());
                picture = System.Convert.ToString(para["PICTURE"].ToString());
                stretch = System.Convert.ToInt32(para["STRETCH"].ToString());

                result = led.LED_AddMovie(nLEDID, num, startx, starty, width, height, transparent, border, picture, stretch);
                break;
            case "LED_MakeObject":
                nLEDID = System.Convert.ToInt32(para["LEDID"].ToString());
                RootType = System.Convert.ToString(para["ROOTTYPE"].ToString());
                ActionMode = System.Convert.ToString(para["ACTIONMODE"].ToString());
                ChapterIndex = System.Convert.ToInt32(para["CHAPTERINDEX"].ToString());
                RegionIndex = System.Convert.ToInt32(para["REGIONINDEX"].ToString());
                LeafIndex = System.Convert.ToInt32(para["LEAFINDEX"].ToString());
                ObjectIndex = System.Convert.ToInt32(para["OBJECTINDEX"].ToString());
                ColorMode = System.Convert.ToString(para["COLORMODE"].ToString());
                result = led.LED_MakeObject(nLEDID, RootType, ActionMode, ChapterIndex, RegionIndex, LeafIndex, ObjectIndex, ColorMode);
                break;
            case "LED_AddDateTimeEx":
                nLEDID = System.Convert.ToInt32(para["LEDID"].ToString());
                num = System.Convert.ToUInt16(para["PNUM"].ToString());
                startx = System.Convert.ToInt32(para["STARTX"].ToString());
                starty = System.Convert.ToInt32(para["STARTY"].ToString());
                width = System.Convert.ToInt32(para["WIDTH"].ToString());
                height = System.Convert.ToInt32(para["HEIGHT"].ToString());
                transparent = System.Convert.ToInt32(para["TRANSPARENT"].ToString());
                border = System.Convert.ToInt32(para["BORDER"].ToString());
                vertical = System.Convert.ToInt32(para["VERTICAL"].ToString());
                fontname = System.Convert.ToString(para["FONTNAME"].ToString());
                fontsize = System.Convert.ToInt32(para["FONTSIZE"].ToString());
                fontcolor = System.Convert.ToInt32(para["FONTCOLOR"].ToString());
                fontstyle = System.Convert.ToString(para["FONTSTYLE"].ToString());
                year_offset = System.Convert.ToInt32(para["YEAR_OFFSET"].ToString());
                month_offset = System.Convert.ToInt32(para["MONTH_OFFSET"].ToString());
                day_offset = System.Convert.ToInt32(para["DAY_OFFSET"].ToString());
                sec_offset = System.Convert.ToInt32(para["SEC_OFFSET"].ToString());
                format = System.Convert.ToString(para["FORMAT"].ToString());
                fontname = System.Text.Encoding.Default.GetString(System.Text.Encoding.GetEncoding("iso-8859-1").GetBytes(fontname as string));
                format = System.Text.Encoding.Default.GetString(System.Text.Encoding.GetEncoding("iso-8859-1").GetBytes(format as string));
                result = led.LED_AddDateTimeEx(nLEDID, num, startx, starty, width, height, transparent, border, vertical, fontname, fontsize, fontcolor, fontstyle,
                year_offset, month_offset, day_offset, sec_offset, format);
                break;
            case "LED_AddClockEx2":
                nLEDID = System.Convert.ToInt32(para["LEDID"].ToString());
                num = System.Convert.ToUInt16(para["PNUM"].ToString());
                startx = System.Convert.ToInt32(para["STARTX"].ToString());
                starty = System.Convert.ToInt32(para["STARTY"].ToString());
                width = System.Convert.ToInt32(para["WIDTH"].ToString());
                height = System.Convert.ToInt32(para["HEIGHT"].ToString());
                transparent = System.Convert.ToInt32(para["TRANSPARENT"].ToString());
                border = System.Convert.ToInt32(para["BORDER"].ToString());
                vertical = System.Convert.ToInt32(para["VERTICAL"].ToString());
                offset = System.Convert.ToInt32(para["OFFSET"].ToString());
                bkcolor = System.Convert.ToUInt32(para["BKCOLOR"].ToString());
                bordercolor = System.Convert.ToUInt32(para["BORDERCOLOR"].ToString());
                borderwidth = System.Convert.ToUInt32(para["BORDERWIDTH"].ToString());
                bordershape = System.Convert.ToString(para["BORDERSHAPE"].ToString());
                dotradius = System.Convert.ToInt32(para["DOTRADIUS"].ToString());
                adotwidth = System.Convert.ToInt32(para["ADOTWIDTH"].ToString());
                adotcolor = System.Convert.ToUInt32(para["ADOTCOLOR"].ToString());
                bdotwidth = System.Convert.ToInt32(para["BDOTWIDTH"].ToString());
                bdotcolor = System.Convert.ToUInt32(para["BDOTCOLOR"].ToString());
                cdotvisible = System.Convert.ToUInt32(para["CDOTVISIBLE"].ToString());
                bdotwidth = System.Convert.ToInt32(para["CDOTWIDTH"].ToString());
                cdotwidth = System.Convert.ToInt32(para["BDOTWIDTH"].ToString());
                cdotcolor = System.Convert.ToUInt32(para["CDOTCOLOR"].ToString());
                hourwidth = System.Convert.ToInt32(para["HOURWIDTH"].ToString());
                hourcolor = System.Convert.ToUInt32(para["HOURCOLOR"].ToString());
                minutewidth = System.Convert.ToInt32(para["MINUTEWIDTH"].ToString());
                minutecolor = System.Convert.ToUInt32(para["MINUTECOLOR"].ToString());
                secondwidth = System.Convert.ToInt32(para["SECONDWIDTH"].ToString());
                secondcolor = System.Convert.ToUInt32(para["SECONDCOLOR"].ToString());
                result = led.LED_AddClockEx2(nLEDID, num, startx, starty, width, height, transparent, border, vertical, offset, bkcolor, bordercolor, borderwidth, bordershape,
                dotradius, adotwidth, adotcolor, bdotwidth, bdotcolor, cdotvisible, cdotwidth, cdotcolor,
                hourwidth, hourcolor, minutewidth, minutecolor, secondwidth, secondcolor);
                break;
            case "LED_SendToScreen":
                //LED_AddChapter(int nLEDID, int num, UInt32 time, string wait)
                nLEDID = System.Convert.ToInt32(para["LEDID"].ToString());
                num = System.Convert.ToUInt16(para["PNUM"].ToString());
                int zip = System.Convert.ToUInt16(para["ZIP"].ToString());
                result = led.LED_SendToScreen(nLEDID, num, zip);
                break;
            default:
                result = "request command can'f find";
                break;

        }
        return result;
    }
}


